package com.winit.schedule.core.task;

/**
 * 任务定义类
 * 
 * @author jianke.zhang 2015-3-18 上午10:18:44
 * @since 1.0
 */
public class ScheduleTaskDefine {

    public static final String BEAN_PREFIX = "uschedule$";

    /**
     * 任务分组
     */
    private String             group;

    /**
     * 任务名称
     */
    private String             taskName;

    /**
     * 任务执行器的类名
     */
    private String             taskDealClass;

    /**
     * 任务接口类型
     */
    private TaskInterfaceType  interfaceType;

    /**
     * 任务是否被排除，被排除的任务将不能被调度执行
     */
    private boolean            exclude     = false;

    public ScheduleTaskDefine(){

    }

    public ScheduleTaskDefine(String group, String name, String className){
        this.group = group;
        this.taskName = name;
        this.taskDealClass = className;
    }

    public ScheduleTaskDefine(String group, String name, String className, boolean exclude){
        this.group = group;
        this.taskName = name;
        this.taskDealClass = className;
        this.exclude = exclude;
    }

    public String getTaskId() {
        return this.group + "$" + this.taskName;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String name) {
        this.taskName = name;
    }

    public String getTaskDealClass() {
        return taskDealClass;
    }

    public void setTaskDealClass(String className) {
        this.taskDealClass = className;
    }

    public boolean isExclude() {
        return exclude;
    }

    public void setExclude(boolean exclude) {
        this.exclude = exclude;
    }

    public TaskInterfaceType getInterfaceType() {
        return interfaceType;
    }

    public void setInterfaceType(TaskInterfaceType interfaceType) {
        this.interfaceType = interfaceType;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ScheduleTaskDefine)) return false;

        ScheduleTaskDefine node = (ScheduleTaskDefine) o;

        if (node.getGroup().equals(this.group) && node.getTaskName().equals(this.taskName)) {
            return true;
        }

        return false;
    }

    public int hashCode() {
        int result = 1;
        result = 31 * result + this.group.hashCode();
        result = 31 * result + this.taskName.hashCode();
        return result;
    }

    public String toString() {
        return "ScheduleTaskDefine[group: " + this.group + ", name:" + this.taskName + ", className:"
               + this.taskDealClass + ", exclude:" + this.exclude + "]";
    }
}
